import Vue from 'vue';
import Router from 'vue-router';
import Home from '@/views/index.vue';
import Layout from '@/layout'
import error404 from '@/views/error/404.vue'
import erroe401 from '@/views/error/401.vue'
Vue.use(Router);
// 公共路由
export const constantRoutes = [
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/index'], resolve),
        name: '首页',
        meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
      }
    ]
  },
  {
    path: '/404',
    component: error404,
    hidden: true
  },
  {
    path: '/401',
    component: erroe401,
    hidden: true
  },

]

const router = new Router({
  mode: "hash",
  routes: constantRoutes,
});
// 全局的前置守卫
router.beforeEach((to, from, next) => {
  next();
});
export default router;